# -*- coding: utf-8 -*-
from flask import Flask, request, jsonify
import json
import manage

app = Flask(__name__)
app.debug = True


@app.route('/auto/create-api-app/', methods=['post'])
def createApiAPP():
    if not request.data:
        return {"error": "无请求体参数"}
    try:
        datas = json.loads(request.data.decode('utf-8'))
        uuid = datas["uuid"]
        envType = datas["envType"]
        datasList = ["", uuid, envType]
    except:
        return {"error": "请求参数不符合格式"}
    result = manage.run(datasList)
    return jsonify(result)


if __name__ == '__main__':
    from libs.config import serverIP, serverPort
    app.run(host=serverIP, port=serverPort)